/********************************** (C) COPYRIGHT *******************************
 * File Name          : ch32v20x_it.c
 * Author             : WCH
 * Version            : V1.0.0
 * Date               : 2023/12/29
 * Description        : Main Interrupt Service Routines.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for 
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "ch32v20x_it.h"

#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

#define TAG                  "interrupt"
#define LOG_SET_LEVEL        LOG_LEVEL_INF
#include "hal_log.h"         /*!< Must be placed after LOG_SET_LEVEL >*/

#if CONFIG_FREERTOS
void NMI_Handler(void) __attribute__((interrupt()));
void HardFault_Handler(void) __attribute__((interrupt()));
#else 
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
#endif
/*********************************************************************
 * @fn      NMI_Handler
 *
 * @brief   This function handles NMI exception.
 *
 * @return  none
 */
void NMI_Handler(void)
{
  while (1)
  {
  }
}

/*********************************************************************
 * @fn      HardFault_Handler
 *
 * @brief   This function handles Hard Fault exception.
 *
 * @return  none
 */
void HardFault_Handler(void)
{
  LOGE("MEPC:   %08lX", __get_MEPC());  // 查看地址：build/project.lst
  LOGE("MTVAL:  %08lX", __get_MTVAL());
  LOGE("MCAUSE: %08lX", __get_MCAUSE());
  NVIC_SystemReset();
  while (1);
}


